﻿using FastEndpoints;
using vite_net.Common;
using vite_net.Controllers.User.Login;
using vite_services.Dict;

namespace vite_net.Controllers.System.Dict
{
    internal sealed class Endpoint : Endpoint<Request, Result<List<Response>>, Mapper>
    {
        public DictServices _dictService { get; set; }
        public override void Configure()
        {
            Get("/dict/items");
            Roles("ADMIN");
        }

        public override async Task HandleAsync(Request r, CancellationToken c)
        {
            var rsponse = await _dictService.GetDictDataByType(r.Type);
            await SendAsync(Result<List<Response>>.Ok(rsponse));
        }
    }
}